package fr.norsys.mapper.console.web;

import uk.ltd.getahead.dwr.ExecutionContext;
import fr.norsys.mapper.console.model.ConsoleCst;
import fr.norsys.mapper.console.model.Filter;
import fr.norsys.mapper.console.model.GlobalFilter;
import fr.norsys.mapper.console.model.IntFilter;
import fr.norsys.mapper.console.service.FilterService;

public class FilterServiceDWR {
	private FilterService filterService;
	public FilterService getFilterService() {
		return filterService;
	}
	public void setFilterService(FilterService filterService) {
		this.filterService = filterService;
	}
	/**
	 * Save the filter in the current intFilter
	 * @param filter
	 * @return 
	 */
	public void save(Filter filter) throws Exception {
		GlobalFilter globalFilter = (GlobalFilter) ExecutionContext.get().getSession().getAttribute(ConsoleCst.GLOBALFILTER);
		IntFilter intFilter = (IntFilter) ExecutionContext.get().getSession().getAttribute(ConsoleCst.INTFILTER);
		filterService.save(filter,intFilter);
		globalFilter.save(intFilter);
	}
}
